/**
 * 
 */
package com.school.adminServlet.cmd;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.school.dao.AdminManagerDao;
import com.school.dao.AdminManagerDaoImpl;

/**
 * @author KK
 *
 */
public class SetResultForm1Command implements AdminCommand {

	/* (non-Javadoc)
	 * @see com.school.adminServlet.cmd.AdminCommand#processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletConfig)
	 */
	public static Logger log = Logger.getLogger(SetResultForm1Command.class.getSimpleName());
	@Override
	public void processRequest(HttpServletRequest req,
			HttpServletResponse resp, ServletConfig config)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String statuss = req.getParameter("result0");
		String examresult[] = req.getParameterValues("set_exam_result");
		String interviewresult[] = req.getParameterValues("set_interview_result");
		
		if(req.getParameterValues("set_exam_result")==null)
		{
			System.out.println("Please select atleast one student to set their exam result--------------kk");
		}
		else
		{
			//	for(int i=0;i<examresult.length;i++)		{System.out.println(examresult[i]);	}
			
			AdminManagerDao ad21 = new AdminManagerDaoImpl();
			
			if(ad21.setExamResult(statuss, examresult) == true)
			{
				req.setAttribute("newsSuccess", true);
			}
			else
			{
				req.setAttribute("errorPage", true);		//set error page true
			}
		}
		
		if(req.getParameterValues("set_interview_result")==null)
		{
			System.out.println("Please select atleast one student to set their interview result--------------kk");
		}
		else
		{
			AdminManagerDao ad22 = new AdminManagerDaoImpl();
			
			if(ad22.setInterviewResult(statuss, interviewresult) == true)
			{
				req.setAttribute("newsSuccess", true);
			}
			else
			{
				req.setAttribute("errorPage", true);		//set error page true
			}	
		}
		
		req.setAttribute("info", true);
		
		req.setAttribute("contactUs", false);
		req.setAttribute("viewAllRegistered", false);
		req.setAttribute("scheduleExam", false);
		req.setAttribute("setExamStatusForm1", false);
		req.setAttribute("scheduleInterview", false);
		req.setAttribute("publishFinalResult", false);
		
		req.setAttribute("profileManage", false);
		req.setAttribute("admission", false);
		req.setAttribute("examManage", false);
		req.setAttribute("timeTable", false);
		req.setAttribute("attendance", false);
		req.setAttribute("studentDetails", false);
		req.setAttribute("manageNews", false);
		req.setAttribute("more", false);
		
		
		
		RequestDispatcher dispatcher = req.getRequestDispatcher("/admin_home.jsp");
		dispatcher.forward(req, resp);
		
		log.info("exited processRequest()+kkkkkkkkkkkkkkkkk");

	}

}
